﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;


namespace vf_test
{
    public enum GeomEntityType
    {
        vf_geom_none = -1,
        vf_geom_any = 0,
        vf_vertex = 1,
        vf_curve = 1 << 1,
        vf_face = 1 << 2,
        vf_loop = 1 << 3,
        vf_body = 1 << 4,
    }

    public enum VfHRESULT
    {
        vf_Success = 0,
        vf_Failure = 1,
        vf_Cancel = 2
    }

    public class VFAdapter
    {
        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfStartLinkWithCAD(Int32 iCadType);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfGetEntityType(UInt64 lID, out GeomEntityType enType);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreatePoint(double x, double y, double z, out UInt64 ptID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCurveCurveIntersection(UInt64 lCurveTag1, UInt64 lCurveTag2, out double x, out double y, out double z, bool bCreatePoint, out UInt64 ptID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCurveSurfaceIntersection(UInt64 lCurveTag1, UInt64 lSurfaceTag1, out double x, out double y, out double z, bool bCreatePoint, out UInt64 ptID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        public static extern VfHRESULT vfSelectSingleByInteractive(GeomEntityType geoType, out UInt64 tagID, [MarshalAs(UnmanagedType.LPWStr)] string strMessage, bool bObjectActionParadigmPossibility);


        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        public static extern VfHRESULT vfSelectMul(
        GeomEntityType geoType,
        out int ptSize,
        out IntPtr pIds,
        [MarshalAs(UnmanagedType.LPWStr)] string strMessage,
         bool bObjectActionParadigmPossibility);


        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfSelectByTag(UInt64 tagID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfClearSeletion();

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfOffsetCurve(UInt64 curveID1, UInt64 surfaceID, double dis, out UInt64 curveID2);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreateCurveBySurfaceIntersection(UInt64 surfaceID1, UInt64 surfaceID2, out UInt64 curveID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfOffsetSurface(UInt64 surfaceID1, double dis, out UInt64 surfaceID2);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreateSurfaceByLoft([In] UInt64[] curveIDs, int num, out UInt64 surfaceID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfSurfaceMerge([In] UInt64[] surfaceIDs, int num, out UInt64 newSurfaceID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreateSurfaceByFill([In] UInt64[] curveIDs, int num, out UInt64 surfaceID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfSurfaceArea(UInt64 surfaceID, out double dArea);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfSurfacePerimeter(UInt64 surfaceID, out double dPerimeter);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfSurfaceWeight(UInt64 surfaceID, out double dWeight);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfMirrorSurface(UInt64 surfaceID1, UInt64 mirrorPlaneID, bool bReserved, out UInt64 surfaceID2);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreateCurveOnSurfaceByTwoPoints(UInt64 pointID1, UInt64 pointID2, UInt64 surfaceID, out UInt64 curveID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfMirrorCurve(UInt64 curveID1, UInt64 mirrorPlane, bool bReserved, out UInt64 curveID2);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreateCurveByProjection(UInt64 curveID1, UInt64 surfaceID, out UInt64 curveID2);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreateSplineCurve([In] UInt64[] pointIDs, int num, bool bControlPt, out UInt64 curveID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreateBodyWithThickedSurface(UInt64 surfaceID, double thickness, out UInt64 bodyID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreateGravityOfSurface(UInt64 surfaceID, [Out] double[] dGravity);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfTestPointOnCurve(UInt64 pointID, UInt64 curveID, out bool bOn);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfTestPointOnSurface(UInt64 pointID, UInt64 surfaceID, out bool bOn);

        // 三批
        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfMousePtOnSurface(ulong surfaceID, out double x, out double y, out double z);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfMirrorObject(ulong objectID1, ulong mirrorPlane, bool bReserved, out ulong objectID2);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreateCurveByMultiCurves(ulong[] curveIDs, int num, bool bReserved, out ulong curveID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCurveTrim(ulong curveID, ulong objTrimingID, out ulong curveID2);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreatePointOnCurve(ulong curveID, double u, out double x, out double y, out double z, out ulong pointID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreatePointOnSurface(ulong surfaceID, double u, double v, out double x, out double y, out double z, out ulong pointID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        public static extern VfHRESULT vfCreateFunctionCurve(int cType, [MarshalAs(UnmanagedType.LPWStr)] string strExpression1,
                                                             [MarshalAs(UnmanagedType.LPWStr)] string strExpression2,
                                                             [MarshalAs(UnmanagedType.LPWStr)] string strExpression3,
                                                             out ulong curveID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfChangeTheColorLineWidth(ulong objectID, out int lineWidth, out int colorR, out int colorG, out int colorB);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfRestoresColorLineWidth(ulong objectID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfCreateRosetteById(ulong faceID, ulong pointID, ulong lineID, double startAngle, double directionAngle,
                                                       double segmentLength,bool isRightHand,out ulong rosetteId, out ulong Line1, out ulong Line2, out ulong Line3,
                                                       out ulong Line4, out ulong Line5, out ulong Line6);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vfRemoveTargetObject(ulong objectID);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        public static extern VfHRESULT vfChangeLineColorWidthInsertMap([In] IntPtr[] inputStringValue);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        public static extern VfHRESULT vfChangeLineColorWidthFromMap([In] IntPtr[] inputStringValue);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        public static extern VfHRESULT vfCreateRosette(
    [In] string faceID,
    [In] string pointID,
    [In] string lineID,
    double startAngle,
    double directionAngle,
    double segmentLength,
    [In] string HandDirection,
    [Out] out IntPtr RosetteID,
    [Out] out IntPtr Line1,
    [Out] out IntPtr Line2,
    [Out] out IntPtr Line3,
    [Out] out IntPtr Line4,
    [Out] out IntPtr Line5,
    [Out] out IntPtr Line6);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
        public static extern VfHRESULT vfSelectionToID(
    [In] string filterType,
    [Out] IntPtr intValue);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT CalcRosetteSegments(out int ptSize, out IntPtr pPts,
                                                       ulong faceID, ulong pointID,
                                                       ulong lineID, double startAngle,
                                                       double directionAngle,
                                                       double segmentLength,
                                                       bool isRightHandDirection);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        public static extern VfHRESULT VF2Create3Dsection(
    [In] string strLaminateName, [In] string strCrossSectionCurve,
    [In] string strComponentType, [In] string strBoundaryType,
    [In] string strScaleType, double dPlyOrLayerScale, double dCoreScale,
    [In] string strVisStyle, [In] string strVisProfileType, double dMinDistance,
    double dCorssSectionOffset, bool bCreateCrossSectionGeometry,
    [In] string strOutputCurveType, bool bGeometryLocked,
    [In] string strDBPath);

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern VfHRESULT vf2DeleteTemporaryObjects();

        [DllImport("VFAdapter.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
        public static extern VfHRESULT vf2Create3DNotes(
    [In] string str3DNotesName, // 3维标注名
    [In] string strLaminate,    // 层合板名
    [In] string strRosette,     // Rosette名
    [In] string strRefOrigin,   // 参考点
    bool bAnnotationLocked,     // 注释锁定
    [In] string strBoundaryType, // 下拉框两个选项，”Net”/”Extended”
    [In] string strAnnotationLeader, // 一个注释(天工不需要)
    [In] string strSummaryInfo,   // 下拉框六个选项字符串 摘要格式
    [In] string strComponentInfo, // 下拉框七个选项字符串 组成格式
    [In] string strHeaderText,    // 表头文本
    [In] string strColumnSeparator, // 列分隔符
    int iLinesPerColumn,            // 每列的行数
    bool    bReverseSequence, // 翻转顺序(默认为false时，从小到大排序;从大到小排序时为true)
    [In] string strDBPath);
    };

   
}
